package com.refusea.train.controller

import com.refusea.train.domain.entity.School
import com.refusea.train.domain.helper.SchoolHelper
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

/**
 * @author Zhang Yan 2024/3/22
 **/
@RestController
@RequestMapping("/api/school")
class SchoolController(private val schoolHelper: SchoolHelper) {

    @GetMapping("/query")
    fun query(q: String): List<School> {
        return schoolHelper.all().filter { it.name.contains(q) }
    }

}
